package com.xxgc.wujiaoservice.controller;

import cn.dev33.satoken.stp.StpUtil;
import com.xxgc.wujiaoservice.entity.UsersEntity;
import com.xxgc.wujiaoservice.entity.UsersEntityRepository;
import com.xxgc.wujiaoservice.result.Result;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 获取用户信息
 */
@RestController
@RequestMapping("/users")
@Tag(name = "用户信息")
public class UserInfoController {

    @Autowired
    private UsersEntityRepository usersEntityRepository;

    @GetMapping("/getUserInfo")
    public Result getUserInfo(){
        //获取用户的id
        int loginIdAsInt = StpUtil.getLoginIdAsInt();
        System.out.println("loginIdAsInt = " + loginIdAsInt);
        UsersEntity usersEntity = usersEntityRepository.getById(loginIdAsInt);
        return Result.success(usersEntity);
    }


}
